# Maintainer: David Runge <dvzrv@archlinux.org>

_name=pysolr
pkgname=python-pysolr
pkgver=3.9.0
pkgrel=6
pkgdesc="Python Solr client"
arch=('any')
url="https://github.com/django-haystack/pysolr"
license=('BSD')
depends=('python-requests')
makedepends=('python-setuptools-scm')
# checkdepends=('python-mock' 'python-pytest' 'solr' 'zookeeper')
optdepends=('python-kazoo: for solrcloud'
            'python-simplejson: for JSON support'
            'solr: for interfacing a local solr instance')
source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz")
sha512sums=('8a8ff1588cd379c248de1a0316f2259239c1e9f25cd6f1d3a71792972bb871d1bad5c9449bdc6673e5b82aab896f8a898959dcc98dbac330d7d32568a23bcdc5')

prepare() {
  mv -v "${_name}-${pkgver}" "$pkgname-$pkgver"
}

build() {
  cd "$pkgname-$pkgver"
  python setup.py build
}

# tests vendor solr *and* zookeeper (including download)
# TODO: write own test script to replace start-solr-test-server.sh
# TODO: package zookeeper, as it's also required for tests
# check() {
#   cd "$pkgname-$pkgver"
#   export PYTHONPATH="build:${PYTHONPATH}"
#   python run-tests.py
# }

package() {
  cd "$pkgname-$pkgver"
  python setup.py install --skip-build \
    --optimize=1 \
    --prefix=/usr \
    --root="${pkgdir}"
  install -vDm 644 {AUTHORS,{CHANGELOG,README}.rst} \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -vDm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
}
